<template>
	<div class="app-container">
		<el-table :data="incidental" border style="width: 100%;">
			<el-table-column fixed type="selection" width="55"></el-table-column>
		    <el-table-column prop="item_name" label="名称"></el-table-column>
		    <el-table-column label="购买数量">
				<template slot-scope="scope">
					<el-input-number v-model="scope.row.pay_num" @change="num" :min="1" :max="999" label="描述文字"></el-input-number>
                </template>
			</el-table-column>
		    <el-table-column prop="price" label="价格"></el-table-column>
		    <el-table-column fixed="right" label="操作" width="180">
		      <template slot-scope="scope">
		        <el-button @click="msg(scope.row)" type="primary" size="small">信息</el-button>
				<el-button @click="shopcar(scope.row)" type="warning" size="small">加入购物车</el-button>
		      </template>
		    </el-table-column>
		</el-table>
	</div>
</template>

<script>
import { queryPayLession } from '@/api/studentRecruit.js'
export default{
	data(){
		return{
			numval:1,
		}
	},
	created() {
		console.log(this.incidental);
		this.incidental.forEach((item) => {
			this.$set(item,'pay_num',1)
		})
	},
	methods:{
		jia(row,index){
			this.incidental[index].pay_num = this.incidental[index].pay_num+1
			console.log(this.incidental[index].pay_num);
		},
		jian(row,index){
			this.incidental[index].pay_num = this.incidental[index].pay_num-1
			console.log(this.incidental[index].pay_num);
		},
		num(value){
			console.log(value);
		},
		msg(){
			console.log('信息');
		},
		shopcar(row){
			row.type = 2
			row.price = parseInt(row.price)
			let resData = {
				unid:row.unid,
				lession_name:row.item_name,
				type:row.type,
				pay_num:row.pay_num,
				price:row.price*row.pay_num,
			}
			console.log('resData',resData);
			this.shopcarlist(resData)
		}
	},
	props:{
		incidental:{
			type: Array,
			default:[]
		},
		shopcarlist:{
			type:Function,
			default:() => {}
		}
	}
}
</script>

<style lang="scss">
	.math{
		display: flex;
		flex-direction: row;
		
		input{
			width: 270px;
		}
	}
	.tex{
		width: 100px;
	}
</style>
